I need to figure out a way to dissolve a polygon in Python using other modules besides ArcPy. I've been using the Python GDAL/OGR for merging shapefiles but I don't see anything to dissolve a polygon. I've been looking into Shapley, Fiona and Pyshp.  I also don't want to use qgis, as importing the qgis.core module gives my script problems.   Any ideas?  **EDIT I'm trying the Fiona approach but am having a hard time configuring it. I installed a .whl of it and it appears to install but when I run something it crashes Python saying   'This application has requested the Runtime to terminate it in an unusual way'  When I try to update the module in Pycharm, I get an error 'gdal version is not defined'
I have been trying to create a function that does basically the same thing that the QGIS "dissolve" function. I thought it would be super easy but well apparently not. So from what I have gathered around, the use of fiona with shapely should be the best option here. I just began to mess around with vector files so this world is pretty new to me and python as well.  For these example, I am working with a county shapefile founded here  So here are some piece of code I gathered but can't find a way to make them work together  For now my best method is the following based on : . It works fine and I get a list of the 52 states as Shapely geometry. Please feel free to comment if there is a more straight forward way to do this part.  from osgeo import ogr from shapely.wkb import loads from numpy import asarray from shapely.ops import cascaded_union  ds = ogr.Open('counties.shp') layer = ds.GetLayer(0)  #create a list of unique states identifier to be able #to loop through them later STATEFP_list = [] for i in range(0 , layer.GetFeatureCount()) :     feature = layer.GetFeature(i)     statefp = feature.GetField('STATEFP')     STATEFP_list.append(statefp)  STATEFP_list = set(STATEFP_list)  #Create a list of merged polygons = states  #to be written to file polygons = []  #do the actual dissolving based on STATEFP #and append polygons for i in STATEFP_list :      county_to_merge = []     layer.SetAttributeFilter("STATEFP = '%s'" %i )      #I am not too sure why "while 1" but it works      while 1:         f = layer.GetNextFeature()         if f is None: break         g = f.geometry()         county_to_merge.append(loads(g.ExportToWkb()))      u = cascaded_union(county_to_merge)     polygons.append(u)  #And now I am totally stuck, I have no idea how to write  #this list of shapely geometry into a shapefile using the #same properties that my source.   So the writing is really not straight forward from what I have seen, I really just want the same shapefile only with the country dissolve into states, I don't even need much of the attribute table but I am curious to see how you can pass it on from the source to the new created shapefile.  I found many pieces of code for writing with fiona but I am never able to make it work with my data. Example from  :  from shapely.geometry import mapping, Polygon import fiona  # Here's an example Shapely geometry poly = Polygon([(0, 0), (0, 1), (1, 1), (0, 0)])  # Define a polygon feature geometry with one attribute schema = {     'geometry': 'Polygon',     'properties': {'id': 'int'}, }  # Write a new Shapefile with fiona.open('my_shp2.shp', 'w', 'ESRI Shapefile', schema) as c:     ## If there are multiple geometries, put the "for" loop here     c.write({         'geometry': mapping(poly),         'properties': {'id': 123},     })   The problem here is how to do the same with a list of geometry and how to recreate the same properties than the source.
"When people do make changes" - which tense is this? Which tense are sentences like:   "When people do make changes good things happen" "Even if monkeys can play an important role, their actions can pose risk to the general public" What does 'close invalidated' mean Recently I flagged  as a duplicate. A few days later, when I checked it again to see if it was closed, I realized it wasn't.    Searching in Meta brought me to , where a comment suggested checking the timeline. So I checked the  and saw that the close flag was set as invalidated.  Does this mean that it was disputed? When I click on it I see only "This item is no longer reviewable." Do I need more reputation (3000+ ?) to view more detailed information? Travelling by bus Alternatively, why does the force created by blowing out air feel so much stronger than the force created by sucking in air?  Ok, so forget the human factor involved in blowing out candles. Consider a vacuum cleaner with a suction end and a blower end. Anyone who has tried it out notices the blower end creates a much stronger force than the suction end, despite the discharge being (more or less) equal at both ends.  Why does this happen? Unable to cover get set in apex test class Do lenses have focal planes or focal spheres/ellipsoids? Possible Duplicates:             Voting on questions played a big role in the site when we didn't have the option to comment on, close, migrate, flag, or edit questions which did not fit the site or required modification to be useful and usable.  As it is, question votes are not much more than a popularity contest, and a lot of bandwidth is taken up on Meta regarding question votes.  Notably:        In most cases a downvote is being given where a good edit should be used instead, or a comment indicating that the question user needs to provide more information.  People are also downvoting in the case of duplicates (or suspected duplicates) when they don't want to do the work of finding the duplicate.  There is no need to downvote to 'alert' other users that a question isn't worth spending time on - if it's bad enough that it can't be fixed, and so bad that you want to be sure others avoid it then it's not worth keeping open.  These are all situations where the person downvoting should be taking a different action.  , and several questions have thrown ideas at how to increase question upvoting artificially, and a  was even implemented to encourage this behavior.  Given all this, I am now convinced that voting on questions is an unnecessary distraction.  Voting no longer provides any useful information about a question, and there are more than adequate means of fixing or removing questions that need work.  Voting makes more sense for sites like Meta where questions aren't really questions, but suggestions and discussions.  For purely Q/A sites such as SO, SF, SU, the voting is superfluous.  The only two possible positive things voting now provides are:   A way for users at lower rep levels to have a voice when they are unable to perform many of the other functions that are needed to fix a question (I contend this is useless, but perhaps they need some sort of outlet) A 'hook' to get new users into the reputation game (which fails frequently because questions aren't getting upvotes, especially questions from new users)   If that is truly the case, then we should consider removing question voting altogether, or removing the effect of question votes on reputation.   Am I wrong? What obvious and explicitly important role does question voting play in our community? How to evaluate  $$\det\begin{bmatrix}1+x_1y_1&amp;\cdots &amp; 1+x_1y_n\\ \vdots &amp; \ddots &amp; \vdots \\ 1+x_ny_1 &amp; \cdots &amp; 1+x_ny_n\end{bmatrix}$$?  I tried factorisation but I have no idea. I could not factor anything out... I need a hint to kick off.   Edit: A conjecture due to multilinearity: if we let $v_j=(x_1y_j,\cdots,x_ny_j)^T$, then my guess would be $$\det\begin{bmatrix}1+x_1y_1&amp;\cdots &amp; 1+x_1y_n\\ \vdots &amp; \ddots &amp; \vdots \\ 1+x_ny_1 &amp; \cdots &amp; 1+x_ny_n\end{bmatrix}=\det(1,v_2,\cdots,v_n)+\det(v_1,1,\cdots,v_n)+\cdots+\det(v_1,v_2,\cdots,1)=\color{red}{0}$$ where $1$ denote $(1,\cdots,1)^T\in \Bbb K^n$,$\Bbb K$ the underlying number field. Dynamic Comparison Operators in PHP Do eyeballs exhibit chromatic aberration? Fairly straightforward question. If not, why not?  I suspect that if they do, it is not perceived due to the regions of highest dispersion being in one's region of lowest visual acuity. For an affine connection $\nabla$, prove the curvature R  $R(X,Y,Z,\alpha)=\alpha(\nabla_X \nabla_Y Z - \nabla_Y \nabla_X Z -\nabla_{[X,Y]}Z)$  with $X,Y,Z$ vector fields and $\alpha$ a co-vector, is a tensor.  So I realise the aim is probably to show that each of the three terms in the expression for $R$ are tensors themselves as then the result will obviously follow. However, I'm not too sure how to show each of these terms are tensors. Do I need to expand out each covariant derivate to get a bunch of connection coefficients and then see some cancellations? Still though, I'm not too sure what I'll want to see after all of this so that I can say "…therefore $R$ is a tensor".  Also, very much related to the question, I'm a bit confused with the difference between  $\nabla_Y Z$ $\space \space $ and $\space \space $  $\nabla_{\mu}\omega$.  The second one I know as the covariant derivative of a 1-form, but what is meant by the covariant derivate of a vector $\textit{field}$? As in, what's the difference between the $\nabla_Y$ and $\nabla_{\mu}$?  Edit: In answering this last question, I have realised that $\nabla_YZ=Y^{\mu}\nabla_{\mu}Z^{\nu}$ and $\nabla_{\mu}\omega=\nabla_{\mu}\omega_{\nu}$. I made a series of outdoor shots with Nikon D5000, with the 18-55mm 1:3.5-5.6G VR kit lens.  On some shots, I see in the EXIF info f/11, and in another shot, f/9.    How can that be, that the f-number is greater than 5.6, when that's listed as the maximum in the lens spec? Disable browser 'Save Password' functionality One of the joys of working for a government healthcare agency is having to deal with all of the paranoia around dealing with PHI (Protected Health Information). Don't get me wrong, I'm all for doing everything possible to protect people's personal information (health, financial, surfing habits, etc.), but sometimes people get a little too jumpy.  Case in point: One of our state customers recently found out that the browser provides the handy feature to save your password. We all know that it has been there for a while and is completely optional and is up to the end user to decide whether or not it is a smart decision to use or not. However, there is a bit of an uproar at the moment and we are being demanded to find a way to disable that functionality for our site.  Question: Is there a way for a site to tell the browser not to offer to remember passwords? I've been around web development a long time but don't know that I have come across that before.  Any help is appreciated. Why aren't we sterilizing N95 masks? I have two directories that should contain the same files and have the same directory structure.  I think that something is missing in one of these directories.  Using the bash shell, is there a way to compare my directories and see if one of them is missing files that are present in the other? Does separation of variables in PDEs give a general solution? When a partial differential equation is solved using the separation of variables method, is the produced solution the most general one that satisfies the equation or have we lost some forms of the solution because of the assumption that it is in the form of separated variables? Break a loop animation (Make Cyclic) to start a new one I've used the 'Make Cyclic' to loop these keyframes (image below). So, I want to break the loop at a certain time to do a new animation (insert another kf to do a different thing than the loop does). Any help how to do this?    Thanks in advance! Show:$$\lim_{n\to\infty}\frac{\sqrt[n]{n!}}{n}= \frac{1}{e}$$  So I can expand the numerator by geometric mean. Letting $C_{n}=\left(\ln(a_{1})+...+\ln(a_{n})\right)/n$. Let the numerator be called $a_{n}$ and the denominator be $b_{n}$ Is there a way to use this statement so that I could force the original sequence into the form of $1/\left(1+\frac{1}{n}\right)^n$ Create unmanaged c++ object in c# I'm running into trouble trying to mount a large iso:  dev@dev-OptiPlex-745:~$ sudo mount -o loop /home/dev/Hämtningar/matlab2011a_64.iso /cdrom mount: warning: /cdrom seems to be mounted read-only. dev@dev-OptiPlex-745:~$    Can you tell me how I should do it?