to_pixels issue
I have following setup:
import smopy
# bounds via http://boundingbox.klokantech.com/
# copy & paste:
bounds = [14.262150,51.665628,14.502597,51.880444]
maxY = bounds[3]
maxX = bounds[2]
minY = bounds[1]
minX = bounds[0]
mymap = smopy.Map((minY, minX, maxY, maxX), z=10)
X, Y = mymap.to_pixels(51.75,14.325)
ax = mymap.show_mpl(figsize=(23,29.7))
ax.plot(X, Y, 'or', ms=50, mew=2);
which produces to the following map:

Here are two things wrong:
- the map is bottom up, maybe because in the
def show_mpltheylimis defined between(self.h, 0)and not from(0, self.h)? - the red dot is not where it is supposed to be. The coordinates are the main station of Cottbus, which is not on this position, even when the map is turned upside-down
Is my code wrong or is the calculation of the lat, lon on the matplotlib image wrong?
The exact same code produces the following image on my system:

I think it is correct?
It may be due to a change in MPL or PIL. Can you run the following code?
import numpy
import matplotlib
import PIL
print "NumPy", numpy.__version__
print "MPL", matplotlib.__version__
print "PIL", PIL.VERSION
On my system: NumPy 1.7.1 MPL 1.3.0 PIL 1.1.7
On my system (MacOS X Mountain Lion):
NumPy 1.6.2
MPL 1.1.1
PIL
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'VERSION'
If I am doin' something like pip install pil --upgrade it tells me,
Requirement already up-to-date: PIL in /Library/Python/2.7/site-packages/PIL
:(
Maybe this is the problem.
Can you zoom in to your rendering? I changed the ylim() definition in smopy, so that the image is not upside down, but the point was slightly wrong in north direction. I wanna take a look if on your rendering too.
Could you try installing Pillow instead of PIL? As far as I understand, PIL is dead, and Pillow is its maintained fork.
I'll try to upload a zoom of the image.
If I am doin' mymap.save_png('bg.png') the image is not upside down. So it might be the ylim() definition in show_mpl() ?
If I am doin' mymap.save_png('bg.png') the image is not upside down. So it might be the ylim() definition in show_mpl() ?
Possibly. If I change the ylim like you did, I get an upside down image (whereas it is currently correct). I'm wondering how it would work for you if you had the same matplotlib version as me.
@sethoscope wrote in his heatmap.py (https://github.com/sethoscope/heatmap)
# If someone wants to use pixel coordinates instead of Lat/Lon, we
# could add an XYProjection. EquirectangularProjection would work,
# but would be upside-down.
Maybe this is the solution?