Tag Info

Hot answers tagged

5

You can use Mapshaper for this, and then dissolve from the command line: mapshaper --dissolve -i your_data.geojson


5

With Python and Fiona, Polygons and MutiPolygons (multi-parts) are different geometries: 1) multi-parts geometries import fiona shape = fiona.open("polygons.shp") # shapefile schema print c.schema {'geometry': 'Polygon', 'properties': OrderedDict([(u'id', 'int:10')])} # first feature first = shape.next() print first (GeoJSON format) {'geometry': ...


5

In QGIS if your polygons do not have any holes or multi-parts: l = iface.activeLayer() for f in l.getFeatures(): print f['NAME'] print 'no. edges: %d' %(len(f.geometry().asPolygon()[0])-1) replace 'NAME' with some identifier in your layer attribute table. Concerning writing to the attribute table check the instructions in the PyQGIS Cookbook - ...


5

Here is a method using arcpy geometry objects. The script creates a rotated hull rectangle around each polygon, splits it into plots, and clips the plots to the original polygon. As Aaron mentions, you could likely achieve this with the fishnet tool, but I could not figure out how to (in Step #2) "use logic to find the ordinal coords" for rotated polygons. ...


4

In InkScape, try saving the image as "Plain SVG" if you're not already doing so. Also try positioning the center of the flag in the upper left corner of the canvas (this is origo of an SVG.)


4

You could automate this approach with Python using the Create Fishnet (Data Management) tool. You can extract all of the pieces of the puzzle to do this analysis with python and then simply plug the pieces into the fishnet function. You need to start by iterating over all of the section polygons. Otherwise, you will get one large fishnet covering the ...


3

Nope, you're pretty much bang on! You have to create a folder called "svg" in your ".qgis2" directory. You should be able to find this in: C:\Users\(your user name)\.qgis2 Then create the new svg folder, insert your flags in there and you should be able to see them in your Style > Symbol interface: For me, QGIS did tend to run a bit slow so it may be a ...


3

I would use either the Con or Reclassify tools to create a new raster with the value range that you are interested in and then perform the raster-to-vector conversion on this newly created raster. Two steps and you're done!


3

In the OGC specification, which can be downloaded here they state: "Polygon rotation is not defined by this standard; actual polygon rotation may be in a clockwise or counter-clockwise direction." In SQL Server Spatial, the geography datatype follows a counter clockwise rule for the outer-ring, and clockwise for the inner rings -- see this MicroSoft ...


3

I don't know that anybody will be able to provide a definitive answer for your question since each vector file format is different and each GIS, in terms of how they internally handle these data, will also be different. But I can tell you for certain that the clockwise ordering is not only for ESRI Shapefiles. There are other formats that use a similar ...


3

The problem is that col.regions expects a vector with values or names for colors and you are giving it factors. When you build your dataframe your string vectors are (by default) turned into factors and the levels of the factors are (by default) ordered, in this case alphabetically. This is the reason why the mapping of the colors to the categories is off. ...


3

You will want to create a ToolControl button that allows you to click on a map as opposed to a button which does something when you click on it. Then grab the point, create a spatialfilter and query your polygon layer, this returns a Feature object which you can return the various address components and populate some form that you created. The bold words ...


2

@DarrenCope made a very good point, your layer contained inconsistencies. Please note: I only posted this as an answer as to include a screenshot of the results, please accept Darren's answer when he posts one as he came up with the correct solution. I used the Multiparts to singleparts function (via Vector > Geometry Tools > Multiparts to singleparts) ...


2

A wiki article Centroid describes a few methods, including this one, which is probably the one used by most GIS tools: Centroid of polygon The centroid of a non-self-intersecting closed polygon, defined by n vertices (x0,y0), (x1,y1), ..., (xn−1,yn−1), is the point (Cx, Cy), where and where A is the polygon's signed area, ...


2

I've updated the original code given here http://stackoverflow.com/questions/26087772/create-polygon-from-set-of-points-distributed/26089377#26089377 Instead of Bezier-based smoothing, you can used the smoothing suggested here http://gis.stackexchange.com/a/24929/8104 with the function spline.poly (as suggested by @aaron) which gives accurate results.


2

In R, you can used the sp package and over function to do this. I adapted an example data set and the solution from this post by Roger Bivand. library(sp) library(rgeos) library(rworldmap) box <- readWKT("POLYGON((-180 90, 180 90, 180 -90, -180 -90, -180 90))") proj4string(box) <- CRS("+proj=cea +datum=WGS84") set.seed(1) pts <- spsample(box, ...


2

You can create square and rectangular grids using the Vector Grid tool under Vector > Research Tools > Vector Grid. To get the required coordinates, I suggest using the Coordinate Capture tool and then input the Xmin, Xmax, Ymin, Ymax from these captured points. Note that the units will be in the coordinate system currently used, so you might want to ...


2

It's easy to do with QGis. Open QGis Drag&Drop the geojson file to qgis use the "dissolve" tool in the vector menu (it's inside a submenu). use the "dissolve all" option from the dropdown this will create a shapefile (check the box to output to the map) which you can then again save as a geojson file by right-clicking it in the layer pane and choosing ...


2

Given a starting point, bearings and distances the Azimuth and Distance plug-in will do this too.


2

You can get polygon exterior and interior points coordinates this way: def extract_poly_coords(geom): if geom.type == 'Polygon': exterior_coords = geom.exterior.coords[:] interior_coords = [] for int in geom.interiors: interior_coords += i.coords[:] elif geom.type == 'MultiPolygon': ...


1

1) With Fiona, you don't need shapely to count the number of points in a polygon/multipolygon. Simply use the resulting GeoJSON format (= a Python dictionary). Polygon simple: jmport fiona shape = fiona.open("simplePoly.shp") # first feature feature = shape.next() geom = feature['geometry'] print geom {'type': 'Polygon', 'coordinates': [[(1.0, 1.0), (1.0, ...


1

The plugin Cadinput might be what you are looking for (https://plugins.qgis.org/plugins/CadInput/). See http://vimeo.com/85052231 for a demonstration.


1

OpenLayers has a GetCentroid function for getting the centre of a polygon if you don't want to bring it in from the database directly: http://dev.openlayers.org/apidocs/files/OpenLayers/Geometry-js.html#OpenLayers.Geometry.getCentroid From there you should just be able to treat the point as a regular point feature. See also this example: ...


1

You could do this using Javascript Topology Suite which will work with Node.js. Start with an empty MultiPolygon (or the first geometry in your collection) and union this with each (Multi)Polygon in your collection. You can only have one format for the whole collection, obviously, as properties are one to one with the geometry in the GeoJSON. Here are some ...


1

You could use a spatial database (like PostGIS). First, you put all your addresses in a table "addresses" with a column "Point" of type Point and a column "Address". CREATE TABLE addresses (Point Point, Address Varchar(50)); Then you put your polygon in another table, let's call it "poly". It can have a column "Polygon" of type Polygon and another column ...


1

I finally found also an R-solution for my problem. The rgeos package offers the get.pts function which allows to extract the number of vertices. As we have learned from the first comments, the number of edges is equal to the number of vertices - 1. Programming a solution for my task in R seems now much easier.


1

Okay, let's rock these features out of the DragBox! There are three options I have found to extract those features from the extent of the DragBox. Considerations and assumptions: I couldn't extract the layer types (raster or vector) from the map.getLayers() object, so let's assume that we stored the feature layers in individual global variables. The ...


1

I've analysed the geometry issues in the attached data, and it seems it does not ONLY have orphaned holes but also geometry validity issues. It's true that an orphaned hole is somehow a geometry validity issue, but rgeos does not handle it in the same way, as for orphaned holes, an error is raised, instead of a simple warning. As you indicate, they are hints ...


1

I've used the Natural Earth shape files - they are great and cover all countries down to an incredible level of detail (railroads!): http://www.naturalearthdata.com Laurent Dupuis has shared his amazing project which shreds ALL of the natural earth data (including all the dbf attributes) straight from the zip file you download, into SQL tables (that his ...


1

There are a couple of options. Option 1 You could do the query exactly like you have it, then add your linestring using GeoJSON on the client. You'd use CartoDB.js to draw you polygon layer and then use Leaflet to add the GeoJSON layer on top. Option 2 Use a multilayer visualization. The bottom layer you could have as you polygons (styled accordingly. ...



Only top voted, non community-wiki answers of a minimum length are eligible