shp2json | convert shapefile zip archives to streaming GeoJSON

 by   substack JavaScript Version: 1.4.0 License: No License

kandi X-RAY | shp2json Summary

kandi X-RAY | shp2json Summary

shp2json is a JavaScript library typically used in Data Preparation applications. shp2json has no bugs, it has no vulnerabilities and it has low support. You can install using 'npm i shp2json' or download it from GitHub, npm.

Convert shapefile zip archives to streaming GeoJSON using [gdal] and [JSONStream] Uses the [gdal native addon] for node.js. No compilation required on most platforms as pre-compiled binaries will be downloaded automatically when you run npm install shp2json.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              shp2json has a low active ecosystem.
              It has 159 star(s) with 41 fork(s). There are 6 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 11 open issues and 5 have been closed. On average issues are closed in 179 days. There are 2 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of shp2json is 1.4.0

            kandi-Quality Quality

              shp2json has 0 bugs and 0 code smells.

            kandi-Security Security

              shp2json has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              shp2json code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              shp2json does not have a standard license declared.
              Check the repository for any license declaration and review the terms closely.
              OutlinedDot
              Without a license, all rights are reserved, and you cannot use the library in your applications.

            kandi-Reuse Reuse

              shp2json releases are not available. You will need to build from source code and install.
              Deployable package is available in npm.
              Installation instructions, examples and code snippets are available.

            Top functions reviewed by kandi - BETA

            kandi has reviewed shp2json and discovered the below as its top functions. This is intended to give you an instant insight into shp2json implemented functionality, and help decide if they suit your requirements.
            • Create a Stream from an svg file
            • write the next feature
            • gets the next layer in the map
            Get all kandi verified functions for this library.

            shp2json Key Features

            No Key Features are available at this moment for shp2json.

            shp2json Examples and Code Snippets

            No Code Snippets are available at this moment for shp2json.

            Community Discussions

            QUESTION

            Mapping Nebraska school districts with D3 v4 - base layer not showing
            Asked 2019-Mar-05 at 16:29

            I am having trouble mapping Nebraska school districts in D3 (v4). (See bl.ock here.) I can map Nebraska counties no problem, but the same code modified for school districts--and pointing to a school district TopoJSON file--gives me a blank page.

            Here's how I created the JSON, based on Mike Bostock's excellent instructions :

            ...

            ANSWER

            Answered 2019-Mar-05 at 16:29

            The issue is you haven't finished setting your projection parameters. You have rotate the map, which is how you should center a conic projection along the x axis. But you haven't centered the map on the y axis, it is centered on the equator. You

            For a conical projection, you can do this one of three ways:

            • Center the map on a central latitude : projection.center([0,y])

            You don't need to use .center with an x value because the map is already centered on the x by rotation, rotation and centering are cumulative

            • Rotate the map to a central latitude and longitude: projection.rotate([-x,-y])

            On a conical projection the rotation on the meridian does not warp the map (generally), we rotate by the negative as we move the earth under us. This option does slightly distort the map relative to the other options - this may be preferrable.

            • Use the projection translation to center the map

            The easiest way is to translate the result while automatically scaling (though you can do this manually too) with projection.fitSize or projection.fitExtent. These methods modify projection.scale and projection.translate. As with centering with .center, you need to keep your rotation - otherwise you'll get an odd tilt to the map. These methods set translate and scale to appropriate values so that your map area contains the desired features:

            Source https://stackoverflow.com/questions/54987130

            QUESTION

            Trouble generating TopoJSON to use with D3's Choropleth example
            Asked 2017-Dec-07 at 06:51

            So, I've been following this tutorial https://bl.ocks.org/mbostock/4060606. Just copying and pasting his code directly allows me to see this functionality in action. However, I would like to do the same thing but at the state scale rather than the whole country. So I went to the census bureau's website and downloaded a shapefile for the counties of Missoui, but I'm having difficulty recreating Mike's TopoJSON file. In fact, I've been at this for days, messing around with TopoJSON, but all of the examples I've found use the deprecated topojson command line tools. Since that doesn't exist anymore, I've been forced to figure out for myself how to generate in the same TopoJSON format, but with no luck. I simply cannot get a Shapefile into the same TopoJSON format that Mike uses in this tutorial.

            So here is how I've been doing it. I'm getting my Shapefile from this website https://www.census.gov/geo/maps-data/data/cbf/cbf_counties.html and going to the Census 2000 tab (because I don't know how else to get only the counties for Missouri from this website) then selecting and downloading Missouri. I then unzip the downloaded file, then move the .shp and .dbf files to a separate folder. Then I run this command to produce the GeoJSON file:

            ...

            ANSWER

            Answered 2017-Dec-07 at 06:51

            There are a couple potential challenges in replicating this map for a single state and it appears you have run into a few of them. You will need to deviate from the example more than you have.

            First, the geographic data your are downloading is composed of latitude longitude pairs - the geographic data the example uses is a pre-projected topojson that is sized to fit in a 960x600 Cartesian plane. You will need to either pre-project your data as well (similar to command line cartography part 1) or project your data on the fly within your block using a geoPath and a geoProjection. Mike does use a geoProjection in his block, a null geoProjection, the default geoProjection for a geoPath. The null projection simply takes coordinates in the json and uses them as svg coordinates with no transform.

            Projection issues are probably the most common cause of seeing neither features nor errors. Since you didn't specify a projection, the features are likely rendered off screen. As the continental US sits in the western hemisphere, longitude values are negative - the US will be drawn to the left of the origin, ie off the screen, since you are using a null projection.

            The second potential issue for you is that your data has different attributes than the example:

            I thought that my TopoJSON file would have attributes like the 'id' attribute that contains the FIPS codes for the counties

            The feature attributes of your topojson:

            Source https://stackoverflow.com/questions/47665224

            QUESTION

            shp2json produces GeoJSON with bounding and coordinates not in (-180,180) range
            Asked 2017-Apr-14 at 20:40

            I am doing @mbostock's tutorial on Command Line Cartography 1. Here is what I've done:

            1) Download the zip file

            wget https://www.arb.ca.gov/ei/gislib/gislib.htm/ca_air_basins.zip (from California Air Resources Board site)

            2) Manually unzip by clicking .zip file (unzip command did not work because downloaded file didn't have 'End-of-central-directory signature')

            2) Convert a shapefile to GeoJSON shp2json CaAirBasin.shp -o ca.json

            3) Make a GeoJSON projection using California Albers (specified in CaAirBasin.prj file):

            geoproject 'd3.geoConicEqualArea().parallels([34, 40.5]).rotate([120, 0]).fitSize([960, 960], d)' < ca.json > ca-albers.json

            Result: I get ca-albers.json (223M) that is much bigger than ca.json (6.3M). In the census tract shapefile used in the tutorial, the file size increases from 10 to 14 M.

            Update: It seems that problem is with shp2json step instead of geoProject step. Looking at CaAirBasin.shp.xml, there are two sets of bounding,bounding and lbounding. In my case,lbounding and coordinate values that are in 100,000s range is used as opposed to (-180, 180) in the tutorial, making projection fail.

            What is a good next step - is there an alternative to shp2json that will work for my case? OR how can I translate my bounding/coordinates to appropriate (-180,180) ones?

            Thank you.

            ...

            ANSWER

            Answered 2017-Apr-14 at 20:40

            Your shapefile is already projected. By passing it through d3.geoConicEqualArea, you are projecting it twice; d3.geoConicEqualArea expects WGS84 (longitude and latitude in degrees) as input, but you’re giving it projected coordinates.

            You can tell that your shapefile is projected by looking at the PRJ file, or by looking at the coordinates of the geometry generated by shp2json: the first point is [-298228.39936644124, 437516.87775637675], which is well outside the expected range of [±180°, ±90°] for longitude and latitude.

            Rather than re-projecting your geometry to a new projection, the easiest thing to do is to just use the projection it’s already in. All you need to do is to translate and scale to fit the desired display size of 960×960. You can use d3.geoIdentity for this.

            Source https://stackoverflow.com/questions/43416774

            QUESTION

            D3.js, trouble initiating shp2json - encoding-indexes error
            Asked 2017-Jan-02 at 03:01

            I'm trying to follow the tutorial Mike Bostock did for Command Line Cartography (which is a great help). Right after installing shapefile and running the shp2json step [shp2json cb_2014_06_tract_500k.shp -o ca.json] I get this error message: “error: Decoder not present. Did you forget to include encoding-indexes.js first?” an error message which originates from the text-encoding package from NPM.

            In trying to diagnoise the problem, I figured I should manually install text-encoding as it's in the shp2json dependency list but, didn't appear to be loading. I also reinstalled node to downgrade from 7.3.0 to 6.9.2 and a number of other things (my hacking around looking for a solution for a few hours) but, am stuck. Is this just a matter of updating a package.json?

            I’m using Windows7, the env variables is set I believe correctly to \Users\myAccount\AppData\Roaming\npm. I’ve installed all packages globally as well. Thanks for any insight.

            ...

            ANSWER

            Answered 2017-Jan-02 at 03:01

            I had the same problem when running the "#prepublish" script here. Then I noticed that Mike's shapefile repo has this information in the README:

            Source https://stackoverflow.com/questions/41412499

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install shp2json

            Make sure you have the unzip command in your PATH.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            Install
          • npm

            npm i shp2json

          • CLONE
          • HTTPS

            https://github.com/substack/shp2json.git

          • CLI

            gh repo clone substack/shp2json

          • sshUrl

            git@github.com:substack/shp2json.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link

            Explore Related Topics

            Consider Popular JavaScript Libraries

            freeCodeCamp

            by freeCodeCamp

            vue

            by vuejs

            react

            by facebook

            bootstrap

            by twbs

            Try Top Libraries by substack

            stream-handbook

            by substackJavaScript

            tape

            by substackJavaScript

            minimist

            by substackJavaScript

            dnode

            by substackJavaScript

            node-optimist

            by substackJavaScript