Tag Info

New answers tagged

2

The thing you are looking at is a sliver geometry. Similar to @sgillies's answer, except use a few buffer parameters to control the chiselled geometry shape: import json from shapely.geometry import shape, JOIN_STYLE eps = 0.001 # epsilon that is approx. the width of slivers, e.g. 1 mm # Load the original polygon from GeoJSON poly = ...


0

You could try the Integrate tool in ArcGIS (arcpy.Integrate_management): http://resources.arcgis.com/en/help/main/10.2/index.html#//00170000002s000000 Be careful, since it can change some vertex location within the tolerance's parameter value.


2

How about dilating and eroding by a small factor eps? geom.buffer(eps).buffer(-eps)


0

My money would be on Polygeo's suggestion in the comments prior to rasterizing. However, working with your polygons, you could select the smaller polygons and save them to a separate file (you'll see why shortly). Then de-buffer (negative buffer value) your polygons. Then split multiparts to single parts (important). Next buffer the result of that ...


1

OK, got it now! Thx for your supply! Just divided the bears_buffer -layer into 4 smaller datasets, ran the intersect tool and loaded the output into excel. Then used the pivot table, worked very fine, but a more simple way would be better. The rest of the data needed, I joined by the spatial join tool.


2

You can download administrative shapefiles from here. Simply select Russia as your Country and Administrative areas as your Subject. You will receive 3 shapefiles of differing administrative levels so you can choose what level you would like. Here is are some attributes for the lowest level: Hope this helps.


1

You have to create a new shapefile of type polygon. The points layer can only contain points. If you set snapping on the point layer, the vertices of the polygon will exactly hit your points.


1

In QGis, use the "convex hull" tool from the vector submenu. From the points shown this creates the following polygons:


1

instead of null fill, use a completely transparent fill, like this reference: https://twitter.com/derekswingley/status/487335272825094144


0

Here's an arcpy solution. Run it within the ArcMap Python window. You need to change the three variables at the top (counties, hospitals, and field) to match your data. The output is an in-memory copy of the counties layer called Counties_output with all the fields from the hospital layer joined to it for the maximum value. If there are multiple occurrences ...


1

Note: Edited answer based on additional info provided by OP Try the following: 1) Combine the county and hospitals datasets, either via a spatial join or with identify (I personally prefer identify so I have a new layer to work with, but either should work). This should give you a single point dataset with all your hospital info, but with the addition of ...


2

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, ...


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': ...


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!


4

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

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


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

Can you use Spatial Join to stamp the IDs into the polygons?


0

You may have multi-part polygons in your file, and the area column would thus be reflecting the total area of all 'parts' of a polygon. You can use the Vector > Geometry Tools > Multiparts to singleparts tool to create single-part polygons, and calculate the $area on those to get the answer you are expecting.


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) ...


0

You could create a grid of small squares that cover the world. Then a script could loop on every adjacent square and while(sum(squares.population) < 1000000) {merge(squares)}. For the last square that would make you jump above 1 million, you could do the same with much smaller squares. You should roams across the squares like a snake, not in line, so the ...


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

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

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

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.


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.


5

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


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 ...


0

you could draw rectangles with points in the line drawn acting as a center for each rectangle something like what has been asked here


1

I had a similar problem and used a kml parser (geoxml3) to locally parse a kml. I later ended up storing each kml file as a database table and looping through the records to plot a polygon. Loading the kml from a server was the slowest of all.


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

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. ...


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 - ...


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. ...


0

The Microsoft Developer Network help docs seem promising. Here is an example from the help on to test for intersection: DECLARE @geom1 geometry; DECLARE @geom2 geometry; DECLARE @result geometry; SELECT @geom1 = GeomCol1 FROM SpatialTable WHERE id = 1; SELECT @geom2 = GeomCol1 FROM SpatialTable WHERE id = 2; SELECT @result = @geom1.STIntersection(@geom2); ...


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. Set up the example data: library(sp) library(rgeos) library(raster) library(rworldmap) box <- readWKT("POLYGON((-180 90, 180 90, 180 -90, -180 -90, -180 90))") proj4string(box) <- CRS("+proj=cea ...


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 ...


0

A workaround would be to re-add the attributes after doing the clip, while converting from SpatialPolygons to SpatialPolygonsDataFrame. clip = gDifference(spdf1,spdf2, byid=TRUE) row.names(clip) = c("p1","p2") spdf3 <-SpatialPolygonsDataFrame(clip,data=as.data.frame(spdf1@data)) spdf3@data variable1 variable2 p1 232 235 p2 242 ...


0

Use ST_DumpPoints to get a set of vertices for each polygon in 3. From that construct Voronoi Polygons around your vertices Dissolve the Voronois by grouping Clip the resulting shapes with your department boundary.


0

There does not seem to be any limitations measuring across the antimeridian with this library: library(geosphere) # small distance across the antimeridian distVincentyEllipsoid(c(-179.999, 0), c(179.999, 0)) # 222.639 # this should be zero, but tiny errors have entered in the maths distVincentyEllipsoid(c(-180, 0), c(180, 0)) # 1.556904e-09 And if you ...


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. ...



Top 50 recent answers are included