We need to import Shapefiles into Drupal, and it seems like the way to go is as nodes with geofields. Spatial Tools looks like the way to go, but it doesn't look like there's anything happening with a D7 version.

I have looked through some of the code and I'm wondering if Spatial Import should be pulled out into its own module. Or, if Spatial Import would become the whole of the D7 module, maybe with Spatial Widget being pulled out into Geofield. It seems like neither Data nor Table Wizard will be making the jump to D7, and I'm unclear on the need for importing shapefiles as some type of entity (Location?).

From what I can tell, the real value of this "module" is parsing shapefiles. If that is indeed the case then maybe that's all it should do, with both geofields and a feeds parser depending on it.

Thoughts Patrick?

CommentFileSizeAuthor
#9 spatial.zip15.82 KBIKE0088
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

phayes’s picture

A port to D7 would be most useful - but i'm not sure I'll be able to get to this anytime soon.

For the shapefile functionality, i'd actually like to move that to the geocode module (https://github.com/phayes/geocode)

Any help here appreciated.

langworthy’s picture

I'm not sure how spatial_import would work with geocode. I began to port spatial_import to D7 here https://github.com/sprice/spatial/tree/7.x-1.x/spatial_import

I ripped out the table wizard stuff, the commit log is terrible, and there's some nasty code that hardcodes fid's but it's reading shapefiles.

jeffschuler’s picture

I'm also interested in importing shapefiles in D7 and not clear, @phayes, about how you see this functionality moving into geocode...

cajmcmahon’s picture

subscribing

mgifford’s picture

@langworthy - any work been done on this since? Have you run it through Coder? Was it based on the git version of the repository? What geo stuff does it work with in D7?

phayes’s picture

There is a port here: https://github.com/affinitybridge/spatial

I'm encouraging them to bring it into D.O ASAP.

dtarc’s picture

It's not quite ready yet, I had to put it on the back burner a bit but we'll need to have this in better shape soon, at which we'll put it in here as the D7 branch.

What's currently in github allows for processing of shapefiles into wkt, for insertion into geofields. It also handles kml.

What is not quite ready yet is a geofield widget that uses a shapefile as its source. So if a node had a file field for shapefiles or kml, a geofield on that node could pull the info from that shapefile.

This will only handle small to medium sized shapefiles. Currently the entire shapefile is read into memory. Ogr2ogr will allow for buffered input, but currently this is not implemented in the D7 spatial.

phayes’s picture

Dave, I think all you need to do is implement a geocoder plugin (ctools based). Check out the geocoder module and see how we implement geotagged-images for an example. If spatial were to declare a geocoder plugin, the rest should happen automagically. I don't think you would get the fancy buffering - but it would be an easy-win first step.

IKE0088’s picture

FileSize
15.82 KB

I just got done running this through coder, and updated to a D7 version. There is one error left, and I cannot seem to find a solution:

spatial_import.feeds.ShapefileParser.inc
•Line 65: Context has been added to t as the third parameter, locale has to be an element in the array. Example: array("context" => "frontpage", "locale" => "de"). (Drupal Docs)
t('Import zipped !shapefile with one or more of these columns: !columns.', array('!shapefile' => l(t('Shapefiles'), 'http://en.wikipedia.org/wiki/Shapefile'), '!columns' => implode(', ', $sources))),

Any assistance would be appreciated. Zip file attached.

langworthy’s picture

phayes’s picture

woo! Awesome, good work folks

dtarc’s picture

IKE0088, I don't think the D6 version run through coder will provide us with very much for D7. Lots of what spatial did in D6 using tables from Data module aren't really necessary in D7.

We still need the geocoder plugin but that shouldn't be too bad.