Tag Info

Hot answers tagged

8

If you're comfortable with C/C++, GEOS: http://trac.osgeo.org/geos If you're comfortable with C#, NTS: http://code.google.com/p/nettopologysuite/ If you're comfortable with Java, JTS: http://tsusiatsoftware.net/jts/main.html If you're comfortable with Python, shapely: https://github.com/Toblerity/Shapely If you're comfortable with Ruby, ffi-geos: ...


7

Lazy geometries are not another kind of geometry. This only describes how Geodjango manages to load, instantiate and use geometry objects, and is pretty much like lazy loading in an O/R mapping framework. If you access a whole bunch of geometry data (lets say from a table), geodjango loads them in text based "Well known text" (WKT) format. If you then pick ...


5

Haven't tried, but found a tweet that looks promising https://mobile.twitter.com/JCSanford/status/281540051203141632 Seems like the concept of "buildpack" is a way to get things loaded on Heroku, and someone has made GEOS iavailable as a buildpack. By setting a custom geos-path you can install Shapely via pip and it will find GEOS.


5

As of Shapely version 1.2.14, coordinates are slicable. This looks very similar to GEOSExtractLine, where a subset of the LineString can be extracted. Here are some examples how you can slice coordinates to extract a new line object: from shapely.geometry import LineString, Point # Original LineString used for examples line = LineString([(30, 50), (60, ...


4

No need to clone any geometries. Also, iterate over geometries[1:] to save one Union(). If osgeo.ogr has something like Shapely's cascaded_union use that instead of accumulating unions in a loop.


4

I used the 2to3 tool (see geographika's answer) to convert Shapely-1.2.13 and then manually had to change 3 lines of code to handle Python 3.x's explicit handling of string and byte encoding. I have put this as a separate answer just for clarity and in case anybody else needs to do the same here are the lines I manually changed: \geos.py (line 97) old: v ...


3

I had the same problem, and here is how I solved it: The problem lies in PolygonBuilder.cpp within the libgeos library. The line causing the problem has actually been fixed already, but the fix is not in the current ubuntu/debian repository that is installed via apt-get. Details of the change can be found here. I downloaded the libgeos from github and ...


3

In this case, it looks like you need to help the dissolve tool along by fixing the topology first. Here's how you can do this in GRASS. When you load the shapefile, this is how GRASS sees it: Each cross marks an area. You can see that there are some crosses on the boundary lines: These are the sliver polygons caused by the slight offset between the ...


3

Use GRASS GIS command v.dissolve (in Sextante plugin -> GRASS Commands -> Vector) If I quickly reproduce you example: The result with v.dissolve: Explanation The problem is easy to understand. A shapefile has no topology, if two areas shared a common border that border would be digitized two times and also stored in duplicate. You see this clearly ...


3

Ok, got this working - and feel like putting the long answer here, as it has a lot of useful GEOS example bits in it. Here we go. Warnings I haven't compiled this - I stripped out a load of project specific stuff and replaced it with a simple Point class which probably needs a copy/assignment operator. But it worked before I did that. I'm not sure this ...


3

In regards to Shapely and Python 3.2: We're not yet testing or deploying Shapely on Python 3 + Windows. There's probably some non-conforming code in the shapely.geometry.geo module that prevents its import. June, 2011 - http://old.nabble.com/Shapely-package-installation-td31879542.html So you could try getting the Shapely source from GitHub and ...


2

I think you have incompatible spatialite and geos packages. In particular, it looks like you have an earlier version of geos installed than 3.3.5. Is it possible you have a distro package and a self-compiled version as well?


2

I would use org2ogr to do the reprojection of each file and wrap the command line in a for loop. #!/bin/bash for i in *.shp do x=`basename $i .shp` outfile = ${x}_eqa.shp ogr2ogr -t_srs epsg:xxxx $outfile $i done You'll need to go to spatialreference.org to look up a relevant epsg code for an equal area projection for your region if you don't ...


2

I would perform both a left and right single-sided offset buffer on one of the linestrings and test if the other linestring crosses both sides of the offset buffer. You would need to use a suitable small buffer distance for your analysis. For example, using Shapely: from shapely.wkt import loads def actually_crosses(A, B, precis=0.0001): """A hybrid ...


2

You also install them using pip. You'll have to specify a requirements.txt file though. It's basically just a text file where you list the Python libraries you want to install. Just put the text file on the root of your repository. Once it's there, you can just run pip like so: $pip install -r requirements.txt Here's an example requirements.txt file ...


2

I'd suggest picking up on using Python with the Rtree and shapely modules. Rtree uses an R-tree index, which can be used to very quickly a point to be contained in a bounding-box of what you describe as a zone, then shapely can check to see if the point is actually within the polygon of each zone (rather than just within the bbox). Shapely uses GEOS library ...


2

The points being returned to you by Google Maps are in lat/lng, which almost always these days means SRID=4326. So change your geometry SRID in your PostGIS table to that: location = geos.Point(data['lng'], data['lat'], srid=4326) Then, when displaying points on a web map the projection of the map is commonly set to the Spherical Mercator coordinate ...


2

You can use the distance_lte function in geodjango to check if your point is in a circle or not. It is the same as ST_Distance method in PostGIS. The method which I have mentioned is drawing a 5 meter radius of a circle to find points from Zipcode models. Returns models where the distance to the geometry field from the lookup geometry is less than or ...


2

If you don't want to build from source we have a public repository of packages for CartoDB for both lucid and precise. Maybe precise packages will work in 13.xx. https://launchpad.net/~cartodb


2

It's not a bug, more like a strategic laziness. 1.X versions of PostGIS only supported GEOMETRYCOLLECTION EMPTY, not other forms of empty. For 2.X I (perhaps foolishly) embraced the full variety of nothings. The result is a not-entirely-complete support of varieties of nothing, made slightly ill-formed by the fact that support libraries like GEOS have their ...


2

The only way I could get POSTGis on "Trusty" was to build from Sources, here is what I used .. sudo mkdir postgis-build cd postgis-build ------------------------------------------------------ then put the script below in a shell script file sudo nano build.sh make it executable and run it sudo chmod a+x build.sh ...


1

You have an older version of GEOS installed. Open the Terminal.app and type geos-config --version your result should be 3.3.3 Now, to find the file being used which geos-config ????? If you install the GEOS version of Kyngchaos, the result should be: geos-config --version 3.4.2 which geos-config ...


1

Final Comments :: Hello Sandro, Before some minutes I found one inlogical solution. (But can't confirm because I am doing Testing right now) Previously while each query run I was making connection to database and closing it after use. (To save the garbage) And each time loading 'spatiallite.dll'. The solution most usually adopted by C or Java apps is ...


1

As Sandro told you on the spatialite mailing list (see https://groups.google.com/forum/#!topic/spatialite-users/6n5ysYQ1oN8) this is a corrupted install of some kind.


1

Hmm as I recall there should be in an sfcgal output in your postgis_full_version() output. Did you compile postgis with sfcgal support? It's not enough to just have sfcgal installed. I see you are right the instructions in docs don't tell you how to compile with sfcgal support. I'll amend that. What you need to add is in your postgis configure ...


1

One idea is to install QGIS with apt-get, instead of synaptic with sudo apt-get install qgis python-qgis following with: sudo apt-get install qgis-plugin-grass to get the grass plugin, as shown here (similar to your link, but the official QGIS guide). This should, as far as I know, recognise the GDAL version (1.10 in your case) already ...


1

The easiest way to upgrade is to use the binaries at http://www.kyngchaos.com/software/qgis


1

You can install geos as a vendored binary on Heroku. This blog post that I wrote details how to do it: http://www.saintsjd.com/2014/05/12/run-vendored-binaries-on-heroku.html


1

Christian, you can't have your circle center and point in long,lat space and have R with mile units. Computational geometry algorithms require you to choose one coordinate system. Latitude and longitude is not a good one to work in, by the way unless your objects are very small in extent. After you transform your points to a local coordinate system and scale ...


1

This sounds similar to the bug reported at https://github.com/mapnik/mapnik/issues/1118. It looks like a geos specific problem, because if I move to Mapnik 2.1 and use the CSV plugin (which accepts reading WKT strings using Mapnik's internal parser not GEOS) then things seem to work just fine. I get: Using this code: import mapnik m = ...



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