trackmaker翻译_使用ogr2​​ogr将svg转换为geojson失败

在尝试使用ogr2ogr将SVG文件转换为GeoJSON时遇到错误。错误表明无法打开SVG数据源。然而,通常情况下,SVG图像可以直接使用,不需要转换。如果SVG文件过大,可以优化文件大小或寻找其他来源的shapefile并转换为GeoJSON。如果需要地理位置数据,获取shapefile并转换会更方便。对于 choropleth 图,可以直接在页面中添加SVG并用D3映射数据。
摘要由CSDN通过智能技术生成

I want to convert it to topojson to use it with d3.js. I first start with svg to geojson conversion, but it fails.

I tried:

ogr2ogr -f "GeoJSON" finland_kunta.json finlandHigh.svg

The error I get:

FAILURE:

Unable to open datasource `finlandHigh.svg' with the following drivers.

-> ESRI Shapefile

-> MapInfo File

-> UK .NTF

-> SDTS

-> TIGER

-> S57

-> DGN

-> VRT

-> REC

-> Memory

-> BNA

-> CSV

-> GML

-> GPX

-> KML

-> GeoJSON

-> GMT

-> GPKG

-> SQLite

-> WAsP

-> PCIDSK

-> OpenFileGDB

-> XPlane

-> AVCBin

-> AVCE00

-> DXF

-> Geoconcept

-> GeoRSS

-> GPSTrackMaker

-> VFK

-> PGDump

-> OSM

-> GPSBabel

-> SUA

-> OpenAir

-> PDS

-> WFS

-> HTF

-> AeronavFAA

-> EDIGEO

-> GFT

-> GME

-> SVG

-> CouchDB

-> Idrisi

-> ARCGEN

-> SEGUKOOA

-> SEGY

-> XLS

-> ODS

-> XLSX

-> ElasticSearch

-> PDF

-> CartoDB

-> SXF

I'm only starting to figure these tools out, so I'm not sure what exactly causes the error. When I open svg, it seems to look fine and have all the elements.

解决方案

Actually in most cases you can use the SVG image as is, no need to convert it to topojson or GeoJSON but there are a few issues to consider:

Is the original SVG file size too big for your application ? If it is then you can optimize the SVG file (For example, with: http://petercollingridge.appspot.com/svg-editor). If that's not enough then you can get a shapefile from another source (For example: http://www.naturalearthdata.com/downloads/) and convert it to GeoJSON (Use ogr2ogr, either through their web interface at http://ogre.adc4gis.com/ or you download it with GDAL at http://trac.osgeo.org/gdal/wiki/DownloadingGdalBinaries). If the resulting file is still too big you can compress with mapshaper (http://www.mapshaper.org/ - it takes both shapefiles and GeoJSON formats!) and if necessary (if your file size is still an issue) convert the resulting map from GeoJSON to topojson (see: http://github.com/mbostock/topojson/wiki).

Do you need to use location data in your map ? (for example, you may need to mark where a certain city is in you map but the city is not drawn on your original SVG) Then it is easier to get a shapefile and convert it to GeoJSON (using ogr2ogr) because most likely you do not have geolocation information on the downloaded SVG file.

If you're creating a choropleth and have no geolocation requirements then you can simply add the SVG directy to your page and use D3 to map data to your image! Once you have the SVG in your page then you can even manually edit all path data to include classes and ids that will make your D3 job easier.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值