Coder Social home page Coder Social logo

csv-to-geojson's Introduction

csv-to-geojson's People

Contributors

fgonzaleziv avatar gavinr avatar hugovk avatar jason-cooke avatar mgi1982 avatar pustur avatar robertleeplummerjr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

csv-to-geojson's Issues

Prevent quotes around certain properties

I have a unix time stamp as a date property in my geojson. With the quote around the timestamp, it can't read it right (fairly obvious). Same with currency. Is there a way to keep certain properties from having quotes around them?

Thanks, btw, for this.

Update http://csv.togeojson.com/

I was going to create an issue or PR that blank lines in the CSV (I had a blank line at the end) result in invalid geoJSON because it ends with {"type":"Feature","geometry":{},"properties":{}}]}.

But I see the latest master has already fixed this in #7 :)

Please could you update the code on the released site?

Thanks for this handy tool!

(One suggestion is to rename your master branch to gh-pages and use GitHub Pages to host directly on http://csv.togeojson.com/, so no need to deploy in the future -- it's always up to date.)

csv2geojson

You might want to steal some tricks from csv2geojson - there's an implementation of delimiter-autodetection, regexes for lat/lon, and tests for some odd things like sexagesimal notation.

Spaces in first line of CSV cause bad or no geometry

I tried to use a simple CSV file, and it forgot to create geometry type & coordinates. However it did leave the coordinates in the properties but it saved them as strings.

Example file used:

Street, City, State, Zip, Misc, Lat, Lon 
800 North Pearl St, Menards, NY, 12204, Work, 42.67948646, -73.73575897

What I got back:

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      **"geometry": {},**
      "properties": {
        "Street": " 800 North Pearl St",
        " City": " Menards",
        " State": " NY",
        " Zip": " 12204",
        " Misc": " Work",
        "  latitude": " 42.67948646",
        " longitude ": " -73.73575897"   
      }

It should be this:

{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [ -73.73575897,42.67948646 ]
},

"properties": {
"Street":" 800 North Pearl St",
"City":" Menards",
"State":" NY",

Handle (and show error) if some rows have no latitude/longitude

If some rows have missing latitude/longitude, that will create invalid GeoJSON so we cannot include those rows.

UI should alert user to which rows were removed from the output GeoJSON

Example CSV:

Id,Name,Latitude,Longitude,a
153,aa,40.172000,-88.834000,b
154,bb,39.216000,-1.051000,b
155,cc,46.471000,-119.333000,b
434,dd,,,b

Outputs:

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "geometry": {
        "type": "Point",
        "coordinates": [
          -88.834,
          40.172
        ]
      },
      "properties": {
        "Id": "153",
        "Name": "aa",
        "a": "b"
      }
    },
    {
      "type": "Feature",
      "geometry": {
        "type": "Point",
        "coordinates": [
          -1.051,
          39.216
        ]
      },
      "properties": {
        "Id": "154",
        "Name": "bb",
        "a": "b"
      }
    },
    {
      "type": "Feature",
      "geometry": {
        "type": "Point",
        "coordinates": [
          -119.333,
          46.471
        ]
      },
      "properties": {
        "Id": "155",
        "Name": "cc",
        "a": "b"
      }
    },
    {
      "type": "Feature",
      "geometry": {},
      "properties": {
        "Id": "434",
        "Name": "dd",
        "a": "b"
      }
    }
  ]
}

Expected:

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "geometry": {
        "type": "Point",
        "coordinates": [
          -88.834,
          40.172
        ]
      },
      "properties": {
        "Id": "153",
        "Name": "aa",
        "a": "b"
      }
    },
    {
      "type": "Feature",
      "geometry": {
        "type": "Point",
        "coordinates": [
          -1.051,
          39.216
        ]
      },
      "properties": {
        "Id": "154",
        "Name": "bb",
        "a": "b"
      }
    },
    {
      "type": "Feature",
      "geometry": {
        "type": "Point",
        "coordinates": [
          -119.333,
          46.471
        ]
      },
      "properties": {
        "Id": "155",
        "Name": "cc",
        "a": "b"
      }
    }
  ]
}

Trailing Newlines Aren't Ignored

If there's a trailing newline (empty row) at the end of the CSV data, a feature with no geometry will be created, breaking a lot of GeoJSON parsers (such as GeoJSON Lint and GitHub's display functionality).

Coordinates shouldn't be quoted

The following is an excerpt from the program's output. Note that the coordinates are in quotes, e.g. "coordinates":["-92.2069692","46.8354471"]. These should not be quoted. That is, the output should be: "coordinates":[-92.2069692,46.8354471].

{"type":"FeatureCollection","features":[{"type":"Feature","geometry":{"type":"Point","coordinates":["-92.2069692","46.8354471"]},"properties":{}},{"type":"Feature","geometry":{"type":"Point","coordinates":["-92.2068811","46.8355317"]},"properties":{}},{"type":"Feature","geometry":{"type":"Point","coordinates":["-92.2069551","46.8354527"]},"properties":{}},{"type":"Feature","geometry":{"type":"Point","coordinates":["-92.2069158","46.8354658"]},"properties":{}}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.