Newbie Question - adding info to shapefile

Contribute and discuss tips, tricks, hints, and ideas related to using QGIS

Newbie Question - adding info to shapefile

Postby Miner on Thu Sep 11, 2008 3:14 am

HI

I have a shapefile that contains polygons that are uniquely identified by a number. I also have some information about areas that are defined by groups of the polygons in the shapefile. What I am trying to do is to allocate this information to the polygon in the shape file.

I have tried obtaining a file of the centroids of each polygon (in the shapefile) and adding the additional information with that centroid & then associating the centroid with the appropriate polygon - unfortunately I seem to end up with the centroid file containing information from shapefile not the other way around.

Any suggestions would be appreciated

Thanks

Miner
Miner
Newbie
Newbie
 
Posts: 2
Joined: Thu Sep 11, 2008 2:00 am

Re: Newbie Question - adding info to shapefile

Postby borysiasty on Sun Sep 14, 2008 3:07 pm

I'm not sure I've understood you properly. Maybe dissolving some boundaries is what you need? You will obtain a new shapefile with polygons including areas of whole groups. Or just do you need to add a new attribute to the existing polygons and fill it with the information? All polygons in group will remain separate, but will contain the same added information.
User avatar
borysiasty
QGIS Master
QGIS Master
 
Posts: 124
Joined: Thu Jun 21, 2007 10:49 pm
Location: Warsaw, Poland

Re: Newbie Question - adding info to shapefile

Postby Miner on Tue Sep 16, 2008 11:37 am

Thanks very much for your considered reply.

Honestly it doesn't really matter whether the solution involves disolving the internal boundries to create a new polygon shapefile or not.

I have been trying to think of how I can better explain what I am trying to get at - so here goes.
I have a shape file of a state that is comprised of say 20 zip codes (polygons). Now this state is comprised of 4 local regions - north east is comprised of zip code areas 1 - 5; south east by zip code areas 6 - 10; south west 11-15 & north west 16-20.
Now I have a number of variables associated with the local regions that I would like to associate with their zip code areas that are contained within them. The end result is that I would havce a polygon or series of polygons that define the say north east local area of the state and be able to display the associated varibales.

I trust this has not confused the situation.

Do you know how to gain this outcome?

Regards

Miner
Miner
Newbie
Newbie
 
Posts: 2
Joined: Thu Sep 11, 2008 2:00 am

Re: Newbie Question - adding info to shapefile

Postby borysiasty on Tue Sep 16, 2008 12:33 pm

1. Add a new column to the attribute table of your shapefile. The native QGIS table editor doesn't support adding fields for shp, so you have to use my Table Manager plugin.
2. Use the native table editor to fill this column with the region number
3. optional: Then you can dissolve boundaries inside, if you want to obtain only 4 big polygons (use geoprocessing plugins)
4. Join your external table with region variables to the shp attribute table with "Join Attributes" from Carson Farmer's fTools Plugin

To install all necessary plugins:
0. You need to have QGIS version between 0.9 and 0.11
1. go to Plugins -> Plugin Installer (if not present, enable it in Plugins -> Plugin Manager)
2. Add my repository "http://bwj.aster.net.pl/qgis/repositories.xml"
3. Install the new version of plugin installer
4. Restart QGIS,
5. go to Plugins -> Fetch Python Plugins (the new installer should appear instead of the old one)
6. Repositories -> Add 3rd party repositories
7. Dozens of plugins will be available on the list
User avatar
borysiasty
QGIS Master
QGIS Master
 
Posts: 124
Joined: Thu Jun 21, 2007 10:49 pm
Location: Warsaw, Poland

Re: Newbie Question - adding info to shapefile

Postby _DR_ on Fri Sep 19, 2008 6:49 pm

borysiasty wrote:2. Add my repository "http://bwj.aster.net.pl/qgis/repositories.xml"


The right URL of repository: "http://bwj.aster.net.pl/qgis/plugins.xml"
_DR_
Newbie
Newbie
 
Posts: 2
Joined: Fri Sep 19, 2008 6:44 pm

Re: Newbie Question - adding info to shapefile

Postby borysiasty on Fri Sep 19, 2008 7:04 pm

Of course yes! Sorry :))
User avatar
borysiasty
QGIS Master
QGIS Master
 
Posts: 124
Joined: Thu Jun 21, 2007 10:49 pm
Location: Warsaw, Poland

Re: Newbie Question - adding info to shapefile

Postby _DR_ on Fri Sep 19, 2008 7:44 pm

Boris,when you plan to realise possibility to save changes directly to the edited table in Table Manager plugin?
_DR_
Newbie
Newbie
 
Posts: 2
Joined: Fri Sep 19, 2008 6:44 pm

Re: Newbie Question - adding info to shapefile

Postby sim on Fri Sep 19, 2008 7:49 pm

I second that, I find it really frustrating, that QGIS doesn't allow to work with attributes of shapefiles like any other GIS software package. This plugin seems like to be an answer, but still, extra step ...
User avatar
sim
Apprentice
Apprentice
 
Posts: 22
Joined: Sun Dec 02, 2007 5:18 am

Re: Newbie Question - adding info to shapefile

Postby borysiasty on Fri Sep 19, 2008 10:11 pm

Actually I'm focused on plugin distribution and installation matter, but before QGIS 1.0 release, which will probably occur in in the end of October, I'm going to improve the table manager as much as possible. However I've done some tests with direct saving and exporting to PostGIS and it seems to be not so simple and easy. And of course not so safe. I don't know yet, which way it will go. I have clear plans for another features, but not yet for direct saving.

So stay tuned, in about one month the plans should be at least definited, and maybe even realised ;)

Sim, that lack is related to the GDAL/OGR library limitations and I don't think it will be improved this year...
User avatar
borysiasty
QGIS Master
QGIS Master
 
Posts: 124
Joined: Thu Jun 21, 2007 10:49 pm
Location: Warsaw, Poland

Re: Newbie Question - adding info to shapefile

Postby sim on Fri Sep 19, 2008 10:47 pm

borysiasty wrote:Sim, that lack is related to the GDAL/OGR library limitations and I don't think it will be improved this year...


I understand, that is why I'm so worried, that there is no clear way out of it. Lack of this simple feature makes it harder to migrate from proprietary software, usually people are reluctant to work with postgis layers.
User avatar
sim
Apprentice
Apprentice
 
Posts: 22
Joined: Sun Dec 02, 2007 5:18 am

Re: Newbie Question - adding info to shapefile

Postby borysiasty on Fri Sep 19, 2008 10:58 pm

I fully agree. That's the reason I'll really try to make my plugin usable for 1.0 premiere day. It's one and only feasible solution for now I think...
User avatar
borysiasty
QGIS Master
QGIS Master
 
Posts: 124
Joined: Thu Jun 21, 2007 10:49 pm
Location: Warsaw, Poland

Re: Newbie Question - adding info to shapefile

Postby sim on Sat Sep 20, 2008 2:10 am

yep, thanks for working on that and let us know, if we can help somehow
User avatar
sim
Apprentice
Apprentice
 
Posts: 22
Joined: Sun Dec 02, 2007 5:18 am

Re: Newbie Question - adding info to shapefile

Postby borysiasty on Sat Sep 20, 2008 7:50 am

Thanks! Stay tuned :)
User avatar
borysiasty
QGIS Master
QGIS Master
 
Posts: 124
Joined: Thu Jun 21, 2007 10:49 pm
Location: Warsaw, Poland

Re: Newbie Question - adding info to shapefile

Postby biodist on Tue Sep 23, 2008 4:43 am

I tried doing this and got the following (on an uptodate ubuntu system). Any suggestions?

Couldn't load plugin geoprocessing due an error when calling its initGui() method

Traceback (most recent call last):
File "", line 1, in
File "/home/mccue/.qgis//python/plugins/geoprocessing/geoprocessing.py", line 83, in initGui
self.actionGeoprocessing = QAction(QIcon(":/plugins/geoprocessing/icon_buffer.xpm"), QCoreApplication.translate("Geoprocessing","Geoprocessing Tool"), self.iface.getMainWindow())
AttributeError: getMainWindow

Python version:
2.5.2 (r252:60911, Jul 31 2008, 17:44:49)
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)]

Python path:
['/home/mccue/apps/share/qgis/python', '/home/mccue/.qgis//python/plugins', '/home/mccue/apps/share/qgis/python/plugins', '/usr/lib/python25.zip', '/usr/lib/python2.5', '/usr/lib/python2.5/plat-linux2', '/usr/lib/python2.5/lib-tk', '/usr/lib/python2.5/lib-dynload', '/usr/local/lib/python2.5/site-packages', '/usr/lib/python2.5/site-packages', '/usr/lib/python2.5/site-packages/Numeric', '/usr/lib/python2.5/site-packages/PIL', '/usr/lib/python2.5/site-packages/gst-0.10', '/var/lib/python-support/python2.5', '/usr/lib/python2.5/site-packages/gtk-2.0', '/var/lib/python-support/python2.5/gtk-2.0']
biodist
Newbie
Newbie
 
Posts: 8
Joined: Tue Jan 15, 2008 5:57 am

Re: Newbie Question - adding info to shapefile

Postby borysiasty on Tue Sep 23, 2008 8:48 am

Do you use QGIS 1.0? It seems so. The plugins in the main repository are mostly for QGIS 0.x. Geoprocessing functions for 1.0 are included to the fTools-beta plugin from Carson Farmer. You find it in his repository for 1.0: http://www.ftools.ca/cfarmerQgisRepo.xml
Note that it's all in beta stage now.
User avatar
borysiasty
QGIS Master
QGIS Master
 
Posts: 124
Joined: Thu Jun 21, 2007 10:49 pm
Location: Warsaw, Poland

Next

Return to Tips/Tricks/Ideas

Who is online

Users browsing this forum: No registered users and 1 guest