Hot answers tagged

49

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


16

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


15

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


14

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


13

Look at Are there any online WKT editors? GeoJSON and WKT OpenLayers vector formats GeoJSON geojson.io GeoJSONLint GeoJSON viewer and others WKT Wicket


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


12

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


11

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

In the file system, browse to the "Coordinate Systems" folder. This will be somewhere like C:\Program Files\ArcGIS\Desktop10.0\Coordinate Systems depending on your version. Place your file in the appropriate directory and it will be available in ArcCatalog and ArcMap in the same place.


10

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


9

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 = 'GEOGCS["GCS_WGS_1984",DATUM["...


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


9

Take a look at Wicket, it's awesome: http://arthur-e.github.io/Wicket/sandbox-gmaps3.html The demo sandbox might be enough for you, if not you could probably use it to develop a simple Javascript app.


8

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


8

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


8

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.


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


7

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

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


6

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


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

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

Since readWKT won't read more than one object at a time, you'll still have to iterate over each row of the dataframe returned from sqlQuery, but you can do it all from within R instead of system calls to ogr2ogr. Here's an example using SpatialPoints: library(RODBC) library(rgeos) con <- odbcDriverConnect('driver={SQL Server}; server=SERVERNAME; ...


6

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) http://blog.jordogskog.no/2013/05/05/...


6

If Python is your thing then you can use GeoMet. It's a Python module that converts GeoJSON to WKT/WKB and vice versa. You can install it directly from the github repository using pip $ pip install git+git://github.com/larsbutler/geomet.git Here is a sample conversion: >>> from geomet import wkt >>> point = {'type': 'Point', '...


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

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

You might try referencing the Microsoft.SqlServer.Types assembly (which I believe is included with the free Sql Server Express edition), then use STGeomFromWKB static method to create a microsoft geometry, which could then be converted into WKT using STAsText. Also note that while Microsoft catches a lot of flak about being proprietary, they do offer ...


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



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