Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #63332

Re: Drawing shaded area depending on distance with latitude and altitude coordinate

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder5.xlned.com!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.009
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'url:sourceforge': 0.03; 'from:addr:yahoo.co.uk': 0.04; 'arrays': 0.09; 'lawrence': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'language.': 0.14; 'columns': 0.16; 'inputs': 0.16; 'numpy': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject: \n ': 0.16; 'subject:Drawing': 0.16; 'subject:area': 0.16; 'subject:distance': 0.16; 'typeerror:': 0.16; 'language': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'module': 0.19; 'code,': 0.22; 'import': 0.22; 'header:User-Agent:1': 0.23; 'error': 0.23; 'certain': 0.27; 'header:X-Complaints-To:1': 0.27; 'header:In- Reply-To:1': 0.27; 'tried': 0.27; 'idea': 0.28; 'point': 0.28; 'function': 0.29; 'skip:p 30': 0.29; 'points': 0.29; 'related': 0.29; 'code': 0.31; 'calculated': 0.31; 'noted': 0.31; 'skip:d 20': 0.34; 'could': 0.34; 'subject:with': 0.35; "can't": 0.35; 'point.': 0.35; 'but': 0.35; 'really': 0.36; 'url:listinfo': 0.36; 'so,': 0.37; 'two': 0.37; 'area': 0.37; 'thank': 0.38; 'skip:[ 10': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'received:org': 0.40; 'length': 0.61; 'such': 0.63; 'skip:n 10': 0.64; 'our': 0.64; 'distance': 0.65; 'here': 0.66; 'between': 0.67; 'as:': 0.81; 'contour': 0.84; 'distances': 0.84; 'isaac': 0.84; 'latitude': 0.84; 'longitude': 0.84; 'received:2': 0.84; 'uae': 0.84; 'won': 0.96
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Mark Lawrence <breamoreboy@yahoo.co.uk>
Subject Re: Drawing shaded area depending on distance with latitude and altitude coordinate
Date Mon, 06 Jan 2014 20:16:53 +0000
References <7f58342b-9b75-4a2c-b98e-cc43a4bb05a6@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host host-2-98-207-36.as13285.net
User-Agent Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.2.0
In-Reply-To <7f58342b-9b75-4a2c-b98e-cc43a4bb05a6@googlegroups.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.5052.1389039434.18130.python-list@python.org> (permalink)
Lines 69
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1389039434 news.xs4all.nl 2868 [2001:888:2000:d::a6]:33354
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:63332

Show key headers only | View raw


On 06/01/2014 20:08, Isaac Won wrote:
> I have tried to make a plot of points with longitude and latitude coordinate, and draw shaded area with distance from one point. So, I thought that I could uae contourf function from matplotlibrary. My code is:
>      import haversine
>      import numpy as np
>      import matplotlib.pyplot as plt
>      with open(filin, 'r') as f:
>      arrays = [map(float, line.split()) for line in f]
>          newa = [[x[1],-x[2]] for x in arrays]
>
>      lat = np.zeros(275)
>      lon = np.zeros(275)
>      for c in range(0,275):
>          lat[c] = newa[c][0]
>          lon[c] = newa[c][1]
>
>      with open(filin, 'r') as f:
>          arrays = [map(float, line.split()) for line in f]
>      newa = [[x[1],-x[2]] for x in arrays]
>
>      lat = np.zeros(275)
>      lon = np.zeros(275)
>      for c in range(0,275):
>          lat[c] = newa[c][0]
>          lon[c] = newa[c][1]
>
>
>      dis = np.zeros(275)
>
>      for c in range(0,275):
>          dis[c] = haversine.distance(newa[0],[lat[c],lon[c]])
>
>      dis1 = [[]]*1
>
>      for c in range(0,275):
>          dis1[0].append(dis[c])
>
>
>      cs = plt.contourf(lon,lat,dis1)
>      cb = plt.colorbar(cs)
>
>      plt.plot(-lon[0],lat[0],'ro')
>      plt.plot(-lon[275],lat[275],'ko')
>      plt.plot(-lon[1:275],lat[1:275],'bo')
>      plt.xlabel('Longitude(West)')
>      plt.ylabel('Latitude(North)')
>      plt.gca().invert_xaxis()
>      plt.show()
>
> My idea in this code was that I could made a shaded contour by distance from a certain point which was noted as newa[0] in the code. I calculated distances between newa[0] and other points by haversine module which calculate distances with longitudes and latitudes of two points. However, whenever I ran this code, I got the error related to X, Y or Z in contourf such as:
>      TypeError: Length of x must be number of columns in z, and length of y must be number of rows.
>
> IF I use meshgrid for X and Y, I also get:
>      TypeError: Inputs x and y must be 1D or 2D.
>
> I just need to draw shaded contour with distance from one point on the top of the plot of each point.
>
> If you give any idea or hint, I will really apprecite. Thank you, Isaac
>

Sorry I can't help directly but can point you here 
https://lists.sourceforge.net/lists/listinfo/matplotlib-users or perhaps 
stackoverflow.

-- 
My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.

Mark Lawrence

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Drawing shaded area depending on distance with latitude and altitude coordinate Isaac Won <winefrog@gmail.com> - 2014-01-06 12:08 -0800
  Re: Drawing shaded area depending on distance with latitude and altitude coordinate Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-01-06 20:16 +0000
  Re: Drawing shaded area depending on distance with latitude and altitude
 coordinate Dave Angel <davea@davea.name> - 2014-01-06 17:46 -0500

csiph-web