2

I have a CSV file with one of the columns containing an array of consecutive lat/longs like the following:

"AK_BROOKSCAMP_2012": [[58.5729804, -155.8339805], [58.5641527, -155.8332666], [58.564154680942856, -155.83317673663385], [58.5506944, -155.8320888], [58.550698762267324, -155.83189015543292], [58.5444388, -155.8313832],[69.6421416, -141.3090805], [69.6242443, -141.3088194], [69.6243276997828, -141.25735013404324], [69.6243166, -141.25735], [69.6063833, -141.2571333], [69.60639585516628, -141.2474533985623], [69.6063861, -141.2540555]], [[69.6992305, -141.1549527], [69.6961833, -141.1549305], [69.6962027, -141.1307082], [69.6992499, -141.1307277], [69.6992305, -141.1549527]]

What is the easiest way for me to import this into QGIS as a polygon or points?

0

Those coordinates could mean anything and they are not really consecutive, there are two lists not just one. Is it the exterior ring and then interior rings? If so, you can turn it into WKT quite easily.

I would do it with some basic text processing.

  • First, because there is some inconsistency in the formatting (did you edit the text already?) either add a space after the comma in -155.8313832],[69.6421416 or make the brackets into double brackets. No idea what would be correct...
  • Replace : with a TAB character and the word POLYGON: \tPOLYGON
  • Replace , with a space
  • Replace ] [ with ,
  • Replace ] with )
  • Replace [ with (

Then import the file as Delimited Text Layer.

To get points instead, use MULTIPOINT instead of POLYGON and remove all the brackets.

Afterwards, use QGIS' "Swap x and y coordinates" tool.

The result looks weird, can you show us what it is supposed to look like?

  • Thanks. It should look like a polygon. How can i plot it on the qgis? i couldn't find the multipoint option. this is my output now, "AK_BROOKSCAMP_2012"\tPOLYGON (58.5729804 -155.8339805 ,58.5641527 -155.8332666 ,58.564154680942856 -155.83317673663385 ,58.5506944 -155.8320888 ,58.550698762267324 -155.83189015543292) Did i get it the format right? – Jovanni Jul 24 '19 at 10:04
  • 1
    WKT uses two parens for single part POLYGON and three for MULTIPOLYGON; you also have X Y flipped as Y X (should be lon lat, ...) – Vince Jul 24 '19 at 11:15
  • The \t should be a literal TAB character. Sadly Stackexchange strips those away. You could also use a semicolon ; as separator. – bugmenot123 Jul 24 '19 at 11:19
  • I couldn't able to make it. Pls share a right syntax so i can import it on qgis. Thanks. – Jovanni Jul 24 '19 at 20:14
  • Try the QuickWKT plugin where you can copy/paste WKT strings and load them as temporary layers in QGIS. This will help you test and validate the syntax. – spatialthoughts Aug 28 '19 at 2:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.