Tag Info

Hot answers tagged

7

It would be easier with arcpy. for i in range(10000): pol_list = [] for j in range(30): pol_list.append("a" + str(i*30 + j + 1) + ".shp") arcpy.Merge_management(pol_list, "b" + str(i+1) + ".shp") EDIT: for a feature class inside a geodatabase, you don't need the + ".shp" anymore, and you can define the workspace using : ...


5

This is a really nice application for a PostgreSQL trigger. To set up a trigger in PostgreSQL, you do two things: Create a user-defined function that is run whenever a trigger is called (can be a row insert, update, or delete) Use a CREATE TRIGGER statement to bind that function to a particular table for a particular operation (in this case, INSERT). ...


5

Unless I'm misunderstanding the question, the shape's .extent property is all you need. with open('out.txt', 'wb') as out_text_file, arcpy.da.SearchCursor('path_to_data', ('msa', 'SHAPE@')) as cur: print >>out_text_file, "msa min_lon max_lon min_lat max_lat" for row in cur: msa, ext = row[0], row[1].extent print ...


5

Here's some R code that does the job, the caveat being we are in cartesian coordinates. The input matrix coords is a 5x2 matrix of x,y columns, with the last point being coincident with the first point. This is what you get out of spatial objects in R when you read a shapefile, for example. thinrect <- function(coords, factor=1/3){ dx = ...


4

If, in the shape file, there is an attribute that you are interested in, or can otherwise search on, use Version 2 (it's safer), otherwise use Version 1.: Version 1: Open the Attribute Table for the shape file. Add a new Field (under Table Options). Name it "Interested" or something. Short Integer is fine. Go into Editing mode and make sure to select ...


4

You could create a new attribute called "dissolve", and calculate it to be whatever unique value you wish to use for the dissolve. Eg, "for some specific countries" you would calculate dissolve to be "Country + State", while for the other countries you would calculate dissolve to be simply "Country".


4

for rounding your convex angles, you can apply successively a negative then a positive buffer of the same radius. For the angles shown on your figure, you are thus applying the method on the blue polygons. the buffer tool in shapely is part of the shapely.geometry package


3

You could drape your geological polygons on the elevation surface you created to make them 3D. Two ways in 3D Analyst are Interpolate Shape and Add Surface Information. For an explanation of both see: http://resources.arcgis.com/en/help/main/10.1/index.html#//00q80000005m000000


3

The solution of @Josh is good. If you are interested only in few polygons this approach perhaps is more quickly: Select polygons you are interested in with your mouse (in map) Right click on polygon layer in TOC. Chose Selection > Create Layer From Selected Features


3

The following explains (1.) how to construct technically a polygon from points and (2.) different methods to construct a polygon from points. 1. Tool to create a polygon from point coordinates I would use the GDAL Python bindings to do that. To give you a starting point have a look at the following script: from osgeo import ogr # you have a list of ...


3

Try polygon.buffer(10, join_style=1).buffer(-10.0, join_style=1) A dilation, rounded (join_style=1), followed by an erosion, rounded. There's a diagram of a similar procedure at http://toblerity.org/shapely/manual.html#object.buffer.


3

This can be solved with a model but there are 4 caveats: You need an Advance (ArcInfo) license This model assumes your rectangle is a rectangle so the 2 vertical sides are longer Your rectangle is constructed from 4 vertices only If you want to automate this then all your rectangles must have the same dimensions So after running this model you you are ...


2

Vince's comments led me to look again at Shapely in Python, and it can do it. In short, the method I used was: get the bounding box of the page/object you want calculate the diagonal of this box, as this will be the minimum length your hatch lines need to be draw a square array of horizontal lines centred on the bounding box's centre, each spaced suitably ...


2

For this kind of conversion, you need to choose the attribute field that you want to store in the grid, because a grid can only have one thematic information. This is the value field that you need to define. Knowing that, you can use one of the "Feature to Raster" tools for the conversion, or in your case maybe Polygon to raster which is more specific (but ...


2

You should use the Polygon to raster function (which requires Spatial analyst extension). In the Value field property you assign which field should be the base of your grid, e.g. which different values your grid will have. Don't worry about Cell assignment type and Priority field, play with them if you don't get the desired result. Depending on how ...


2

You can use functions from the rgeos package to extract such regions (e.g. gIntersection, gDifference). I use gDifference in this example, because gIntersection returns a SpatialCollections object here: # define rectangular region y_lim <- c(-1, 1)*23.5 rect_lim <- cbind(c(rep(bbox(ao)["x", ], each=2), bbox(ao)["x", 1]), c(y_lim, ...


2

you can use raster calculator to set your 0 values to NoData. Con(condition, value if true, value if false) will set the false value to Nodata if it is left blank. in your case, you could use Con(raster== 1, 1) a more generic code would be Con(raster!=0, raster) when you convert to polygon, NoData pixels will be ignored. Note that you can make ...


2

You may instead want to produce a Concave Hull (that is, replace ST_ConvexHull with ST_ConcaveHull as well as possibly experimenting with tweaking the second and third optional target_percent and allow_holes parameters). It may still be disappointingly simple depending on the target_percent you set, but it will most likely be closer to the ideal shape you ...


1

If your ultimate aim is to remove all of the islands and if the island polygons have the same attributes and assuming you are using ArcGIS then you can use the Dissolve tool and bypass the need to select them: QGIS has a tool also called dissolve which will also allow you to select and attribute field to base the dissolve on:


1

The closest thing we have in Python to a standard built-in Polygon is defined in "A Python Protocol for Geospatial Data": https://gist.github.com/sgillies/2217756. The most straightforward way to get a Python polygon is to do this: # you have a list of points listPoint = [[13.415449261665342, 52.502674590782519],[13.416039347648621, ...


1

The most common spatial file format is a shapefile, which your data is most likely in. The shapefile is actually a composite of 3 mandatory files and (commonly) several ancillary files. .shp includes the feature geometry .shx an index file allowing for speedy referencing .dbf the feature attributes Ancillary (often generated on-the-fly by GIS software) ...


1

You can create borders by using Polygon to Line tool for each polygon. Then use Near tool on these two borders.


1

255 is the default NoData value in QGIS. I am not sure, what exactly the problem is with the way you tried it, but you could use the GDAL Python bindings to do what you want. For instance the following script converts your shp to a polygon based on the attribute NAME_2_NUM. Import the libraries import ogr, gdal, osr Open your shapefile source_ds = ...


1

I created an ArcGIS Create Custom Grid tool that could be useful for this. However, it might have trouble if any of the rectangles are oriented like a diamond shape. You would set the vertical division to 3 and leave the horizontal to 0. After the tool is ran you need to use the Split Polygons tool in the Advanced Editing toolbar. If you use it, let me ...


1

you can do it using this SQL code SELECT row_to_json(fc) FROM ( SELECT 'FeatureCollection' As type, array_to_json(array_agg(f)) As features FROM (SELECT 'Feature' As type, ST_AsGeoJSON(lg.geom)::json As geometry, ( select row_to_json(t) from (select FIELD_1, FIELD_2, FIELD_N) t ) As properties FROM MY_TABLE_OR_VIEW As lg ) ...


1

In my experience this problem is nearly always caused by: High precision in your coordinates (43.231499999999996), combined with Lines that are almost coincident but not identical The "nudge" approach of the ST_Buffer solutions lets you get away with #2, but anything you can do to resolve these underlying causes, like snapping your geometry to a 1e-6 ...


1

I ran into this same problem (Postgres 9.1.4, PostGIS 2.1.1), and the only thing that worked for me was to wrap the geometry with a very small buffer. SELECT ST_Intersection( (SELECT geom FROM table1), ST_Union(ST_Buffer(geom, 0.0000001)) ) FROM table2 ST_MakeValid didn't work for me, nor did the combination of ST_Node and ST_Dump. The buffer didn't ...



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