Tag Info

Hot answers tagged

34

Try "QuickWKT" plugin. You have to allow experimental plugins to be able to install it.


14

The geopy module provides the Vincenty formula, which provides accurate ellipsoid distances. Couple this with the wkt loading in Shapely, and you have reasonably simple code: from geopy import distance from shapely.wkt import loads line_wkt="LINESTRING(3.0 4.0, 3.1 4.1)" # a number of other elipsoids are supported distance.VincentyDistance.ELLIPSOID = ...


13

A da.searchcursor should work for you. for row in arcpy.da.SearchCursor("path2data", ["SHAPE@WKT"]): print row[0] POINT Z (-119.53753379999995 49.854383300000052 303.14500000000407) doc here: http://resources.arcgis.com/en/help/main/10.1/index.html#//002z0000001t000000 Note: SHAPE@JSON, SHAPE@WKB, and SHAPE@WKT tokens were made available ...


12

As far as I know WKT doesn't really support any kind of label as it just represents the geometry itself. What you could do is however just store it as comma separated list eg: feature1label, {WKT string} feature2label, {WKT string} You should then be able to display this with X GIS program. QGIS can open and display text files with a comma separated ...


10

Indeed there is! Look here for how to achieve it with the Add Delimited Text Layer plugin. Essentially you create a CSV file (although you should use a delimiter other than comma), where one column is the WKT representation of your geometry. Then when you select that file in the plugin, it picks up that there is a WKT column, and does the right thing. I ...


10

I was able to export to CSV, using other than a comma, by separating the layer creation options in the Save As.. dialog with linebreaks. Neither comma, nor space-separating them (even when they were in quotes) worked, but the linebreaks did the trick. To emphasize.. THIS APPROACH WORKED (linebreak-separated): GEOMETRY=AS_WKT SEPARATOR=SEMICOLON ...


10

Well known text for geometry is defined in OGC 01-103r4 (amongst other places). Section 7 of that document provides the syntax. There is also a list of SQL functions relating to those in Part 2 of the Simple Features spec (also an OGC product). The ISO documents are just a more expensive way to get much the same thing. There are useful extensions such as ...


9

Using the IWkb interface does a nice job at converting between an IGeometry and WKB. From a WKB you can use the Microsoft.SqlServer.Types library to convert a WKB to SqlGeometry then back to WKT. IWkb wkb = geometry as (IWkb); //(Where geometry is an instance of IGeometry) byte[] wkb_bytes = new byte[wkb.WkbSize]; int byte_count = wkb.WkbSize; ...


7

The OGR Spatial Reference part of GDAL should do the trick. capooti provided an excellent answer to another question which demonstrates how to peform the translation from a shapefile to WKT. You may also want to check out the class reference. The reverse is simply: from osgeo import osr srs = osr.SpatialReference() wkt_text = ...


7

There are no built-in checks for this in OpenLayers, but it should be possible to implement one quite easily. The Polygon class has a Components property which holds several LinearRings, the first ring beeing the outer ring and the consecutive ones (if any) represents holes. To find self-intersections you could make a function that loops the induvidual ...


6

I have looked at your data and the book example, the problem is that there are three invalid polygons in data that are processed in the book: GSHHS_l_L1.shp ID = 92-W POLYGON ((-180.0 71.514793999999995,-179.69008299999999 71.577888999999999,-178.648889 71.577416999999997,-178.40644399999999 71.549916999999994,-177.406306 71.244167000000004,-177.877444 ...


6

How about using GDAL's OGR .NET bindings? http://bjarte.com/post/gdal-in-csharp and its KML driver through libkml http://www.gdal.org/ogr/drv_libkml.html Alternatively, you could use libkml directly.


6

Shapely deals with geometric objects, not features or collections of features. See the manual on shape(). Your code (with JSON) could be: import json from shapely.geometry import shape f = open('wijken.json', 'r') js = json.load(f) f.close() for f in js['features']: s = shape(f['geometry']) ...


6

Well Known Text is not meant for saving layers like shape files that consists of many objects. WKT defines how to represent geometry of one object. That geometry could be single or multi part. Multi part geometries mean that geometry of one object consists of many parts. For example Hawaiian Islands could be represented as one object but it consists of many ...


6

why not use ST_GeomFromGeoJSON which takes as input a geojson representation of a geometry and outputs a PostGIS geometry object. ST_AsGeoJSON, the inverse see Creating GeoJSON Feature Collections with JSON and PostGIS functions or ST_GeomFromGeoJSON from OpenGeo. To convert to WKT, use ST_AsText , the reverse of ST_GeomFromText() which return the ...


6

While PostGIS can handle mixed geometry types, this won't help you for QGIS. Regardless of their source all layers in QGIS can only be of a single geometry type.


5

In the past, I've used Sharpmap's converter, but I had to get to WKB first. I don't know if it is the best option now. SharpMap.Geometries.IGeometry sharpGeom = SharpMap.Converters.WellKnownBinary.GeometryFromWKB.Parse(geombytes); wkt = SharpMap.Converters.WellKnownText.GeometryToWKT.Write(sharpGeom); I also don't know of where the current SharpMap ...


5

When in doubt go to the OGC Spec (http://portal.opengeospatial.org/modules/admin/license_agreement.php?suppressHeaders=0&access_license_id=3&target=http://portal.opengeospatial.org/files/index.php?artifact_id=25355) which when you follow through all the BNF on page 53 indicates that a period or a comma are acceptable decimal points.


5

If you want to use PostGIS to do the conversion, you can choose from the following functions: bytea WKB = ST_AsBinary(geometry); text WKT = ST_AsText(geometry); geometry = ST_GeomFromWKB(bytea WKB, SRID); geometry = ST_GeometryFromText(text WKT, SRID); More: http://postgis.net/docs/manual-1.5/ch04.html#OpenGISWKBWKT


5

I've run your coordinates through gdaltransform: $ gdaltransform -s_srs EPSG:32017 -t_srs EPSG:4326 759232.003438, 1149854.52147 -77.6116223688997 43.1517747887723 0 And it appears to come up with the right answer. This means that proj4 (which GDAL and PyProj are based on) is doing the right thing. Sometimes these sorts of errors can be caused by ...


5

You can use MapScript (part of MapServer) to make images from any sort of geometry. With (e.g.) MapScript for PHP, you could build a geometry from a WKT string with ShapeObj ms_shapeObjFromWkt(string wkt), make the style look good, then render an image object with imageObj draw() (see an example). There are different flavours of Mapscript, including for ...


5

Looks like you have a self-intersection, which SQL Server no likey. I'm surprised it even got loaded into the database in the first place. Try running MakeValid() and see what it does to the shape. You don't have to test it on the original data, just make a new one on the fly in Management Studio. What's interesting is that SQL Server will plot it: But ...


5

There are two possibilities here (see http://en.wikipedia.org/wiki/Well-known_text for more possibilities): LineString - LINESTRING (30 10, 10 30, 40 40) MultiLineString - MULTILINESTRING ((10 10, 20 20, 10 40), (40 40, 30 30, 40 20, 30 10)) Currently you have LINESTRING and (( which is wrong. UPDATE There is also a problem with the commas as Jason ...


5

The OGC WKT and WKB specifications never explicitly addressed how to encode higher dimensionality, so it would not be surprising if Oracle either (a) did not encode those dimensions at all or (b) did so in a way that is not consistent with formats PostGIS can ingest. Absent any examples of Oracle output, I'm just guessing. You might find that a ...


5

Ogr2ogr translates vector data sources between different formats. Shape file is one kind of data source format but WKT is not. WKT is just a way to represent geometries in a human understandable way. Data source consists of features/objects that consists of a geometry and attributes. The ogr2ogr command you specified in your previous question translates ...


5

The only solution pure javascript solution I've found so far (and I did not try) is https://github.com/thejefflarson/wkb.js. It's only an incomplete WKB parser (it converts WKB to a js object you can transform to WKT) An alternative way to wkb on javascript side can be the experimental twkb (not a standard at the moment) ...


5

As the geometry is in the WTK-format and is of the type polygon, you will specify this in your vrt-file. So your vrt file should look someting like this: <OGRVRTDataSource> <OGRVRTLayer name="parcel"> <SrcDataSource>parcel.csv</SrcDataSource> <GeometryType>wkbPolygon</GeometryType> ...


5

MySQL should be following the WKT specification that was detailed by the Open Geospatial Consortium's Simple Feature Access - Part 1: Common Architecture. The text you have is not valid WKT, and no GIS software will accept it (generally it will raise a parse error). Commas are used to separate coordinates and spaces between components of each coordinate. ...


5

In QGIS 2.0 you can use the following function in the field calculator. geomToWKT( $geometry )


4

If you can work with Java, the JTS Topology Suite can perform such translation by using the classes com.vividsolutions.jts.io.WKBReader and com.vividsolutions.jts.geom.Geometry. A code like this should get the geometry in Well-Known Text format: String wkbString = "0101000000cdcccccc170d2241b81e859bcb405241"; // geometry in WKB format to be translated to ...



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