473,385 Members | 1,531 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Read polyline data from postgres/postgis database

Hi,

I hope i don't spam this thread, I did not want to open a new thread. I'm a noob here (programming). I need help with creating the program. I need to connect to the database- postgres/postgis (only polylines in there) using Python and pull data from it and plot them (visualize on screen). Can someone help? The easiest way for me would have been to have a code which I could adjust to my database.

Thanks a lot
Oct 20 '09 #1
6 3769
Glenton
391 Expert 256MB
Hi

Your best bet is to start a new thread, with more specific details about what you want to do, and what you've tried.

You'll find people happy to engage, with details, but less happy to engage with generalities, or when the impression is given that you haven't tried yourself.

Try to state the big picture of what you're trying to do, as well as the details, because sometimes people with experience know some shortcuts which you haven't thought off.

Best
Oct 21 '09 #2
bvdet
2,851 Expert Mod 2GB
isaacmckensey,

I created a new thread for your question. Asking a new question in an existing thread is called "hijacking".

Matplotlib would be the obvious choice for plotting the data. Reading the data is the first hurdle. Personally, I have no experience with postgres/postgis. If the data was in a simple text file, I may be able to help you.

Were you planning to read the database using Python?

BV
Moderator
Oct 21 '09 #3
Thanks for answers!

Yes, I planned to read the database using the Python. I heard for matplotlib, I think it would be the most appropriate for my project. Whether it would be helpful using psycopg lib?- I'm not sure what's the difference, and as I said, I'm complete noob here. I started to read some tutorials and 'Python for beginners', I hope to learn something.
I'm not sure if the data is a simple text file, but in my database i have table with 3 columns: id, admapkey (both 'integer' type) and third column is 'geometry' type of data. Data from third column looks like this:

0103000000010000000E000000A857CA9A564455413AB4C8B6 775B5341B6D1007E56445541B81E859B7B5B5341BE9F1A1B5C 445541386744457B5B534190A0F83D5C44554165AA1....... .........................

I don't know what to do with this 'coded' coordinates :).

I don't know how to start programing but I think that the sequence should look like this; first i have to import libraries, connect to database somehow, then read the database and get the coordinates and the final step would be to show polylines graphically.

Thanks for your help and your time
Oct 21 '09 #4
bvdet
2,851 Expert Mod 2GB
You might try MySQLdb (user guide) which works similar to psycopg2.
Oct 21 '09 #5
Glenton
391 Expert 256MB
Hi

I think you've got the steps right. It's just a question of putting it all together. Python is almost certainly the right choice for you. A couple of things remain a little unclear to me.

1. the format of your data. For example if you open it with wordpad or some similar text editor what does it look like. You could try something like:
Expand|Select|Wrap|Line Numbers
  1. myFile = open("yourGISfilename.whatever","r") 
  2. for i,line in enumerate(myFile):
  3.     if i>10: break
  4.     print i, line
  5. myFile.close()
  6.  
This should print out the first ten lines of your file. Post back what you get and it will help us to determine whether this very basic approach will be sufficient, or if you need something more.

2. the decoding of your third column. This string is meaningless to me. However, if you know what it means, then extracting the plotable data should be quite easy. There are a number of tricks. Regular expressions is a common one - hugely powerful, but may take a minute to get your head around if you've not seen them before. Otherwise there are many other functions for fiddling around with strings.

By the time these two are done, the rest is pretty standard. But let's get to the point where you can extract the data, and then we'll move on to the next bit.

Best
Oct 22 '09 #6
Hi,

allthough the topic is a little old i try to clear some points here.

1. your 'coded' geometry means sth. like <geom_type>(List_of_coordinates), eg. MULTIPOYGON((1 1, 2 2, 0 1), (5 0, 2 1, 3 4)).
2. Do not know if there is the one file that contains whole database-data in postgres.
3. When only want to visualize your databse, why dont you use some GIS-software (QGIS, OpenJump). Then you have many possibilities of adding a layer into your map (for you it might be sth. like add postgis-layer). Or do you want to plot your data into a special browser?

Best regards
Oct 8 '10 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Chris | last post by:
Here's the situation: I work at a scientific institution and I have a portable electronic device which is used to take measurements. The device produces a very small amount of numerical data,...
4
by: francis70 | last post by:
Hi, I have these 2 problem? Is there a way in Oracle to read UNCOMMITED data. i.e. in Oracle the normal behaviour is that a user's updates to a table are visible to other users ONLY when the...
1
by: Julia | last post by:
Hi, I have basic questions regarding ASP.NET site I am going to use Microsoft application configuration block and I wonder 1.does caching read only data in the application can hurt ...
5
by: mantrid | last post by:
Hello My web hosting company has lost my data due to the mysql software failing, it only affected those people using innoDB engine. I asked them why they didnt restore from a back up. They said...
1
by: varathasiva | last post by:
Hi Every Body, Can i instal postgres sql database in windows 2000 server.Hw i can instal.Pls help to me. With Regards Siva
2
by: Ed | last post by:
Hope someone can help me out... I have been tasked to read some image data from an sql database and save the files to flat files. OK, sounds easy as I'v used BLOBs before. But this is an old...
2
by: Christoph Krammer | last post by:
Hello, I try to write a python application with wx that shows images from a MySQL database. I use the following code to connect and get data when some event was triggered: dbconn =...
1
by: =?Utf-8?B?SHVzYW0=?= | last post by:
Hi EveryBody: I have probelm that I hung with for three weeks, My problem is I want to read Binary data from database. I will told you what I did : first I declear an array byte and I cast the...
10
by: CDFTim | last post by:
O.K. that was a long Title... Can you help / show me how I would......... I am going to long windedly try to paint this picture. Backround: I have an html page that has a marquee function in it to...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.