What exactly is meant by the wavelength of a photon? I've been thinking about this for quite some time, and from looking online I haven't found a satisfying answer.
Lots of photons, such as visible-light photons have very small wavelength (which from my understanding of basic physics is the distance between two crests/troughs), but I also know that some EM waves have wavelengths a few metres or even kilometres long e.g radio waves. 
What keeps me up at night is the question "How can a photon have a wavelength of a few kilometres and yet still be thought of as a particle?"
Does this mean that one individual photon is several kilometres long? If so, wouldn't it be subject to so many variations between the beginning of the wave and its end?
I realise that matter is also wave-like, where it's uncertainty in position is given by its De Broglie wavelength. Does this apply to the photon?
In other words, is the wavelength of a photon simply the uncertainty in its position?
 A: The photon is an elementary particle in the standard model of particle physics. It does not have a wavelength. It is characterized in the table as a point particle with mass zero and spin one. Its energy is given by $E=h\nu$, where $\nu$ is the frequency of the classical electromagnetic wave which can be built up by photons of the same energy.
This is where the confusion comes. The wavelength and frequency characterize the emergent electromagnetic wave from very many photons. How the classical wave emerges can be seen here although it needs a quantum field theory background to understand it. The photon, as a quantum mechanical entity, has a  quantum mechanical wavefunction. This wavefunction complex conjugate squared gives the probability density for the specific photon to be at $(x,y,z,t)$. The frequency in the wavefunction is the frequency of the possible emergent classical wave, but for the individual photon it is only connected with probability of manifestation, as for example in the single photon double slit experiments.


single-photon camera recording of photons from a double slit illuminated by very weak laser light. Left to right: single frame, superposition of 200, 1’000, and 500’000 frames

you ask:

"How can a photon have a wavelength of a few kilometres and yet still be thought of as a particle?

It does not. It takes zillions of photons to build up the classical electromagnetic wave. In the photos above each individual photon gives a little dot. The build up gives the probability density distribution for photons, and lo, there is a frequency associated with the interference pattern, even though the photon manifests individually as a dot at the $(x,y)$ of the screen.
That is why we need quantum mechanics.
Edit after this question became the main duplicate of another one, where I have a long answer/comment that might be of interest to readers.
Does a single photon have a wavelength or not? [duplicate]
A: My answer is close to that of @AnnaV but there is a subtle difference. The wave function is not the result of many photons, but rather gives the expectation value of a measurement. Maxwell's equations are to photons  what the Schrödinger and Dirac equation are to electrons. Their solutions predict statistical observations of photons. Electrons do not have a wavelength, only electron wave functions have. The same is true for photons.
A: Concerning massless particles, don't forget that the spacetime of their lightlike worldline is empty (= zero). That means that the point of emission and of absorption are adjacent in spacetime, even if the space interval between them measures billions of lightyears. By consequence, there is no problem for the transmission of particle characteristics for massless particles.
The wave of a photon is propagating through space with velocity c, and the lenght of a wave is what we can measure in space (with a meterstick), even if the spacetime interval is zero.
This rule does not apply to photons moving at speed v < c through matter. The particle characteristics are transmitted, but the spacetime interval of the worldline of their timelike movement with speed v < c is not empty. This is one of the phenomena of quantum nonlocality, and we can only describe and calculate it, but we haven't got an explanation yet.
A: It had been known for a long time that light showed interference effects, just as in other waves such as sound and water waves. So in the double slit experiment with monochromatic light you get the light and dark bands on the screen, from which you can work out a wavelength for the light. It was thus assumed that light being a wave there must be a vibrating medium to transmit it, which they called the ether. The big difference between light and other known waves was that for light there was no alternating physical phenomenon such as the height of water or pressure of air which for classical waves could be directly measured. The ether theory was knocked on the head by Planck and Einstein when light became a particle, and Max Born gave the only possible feasible explanation of the interference effect, that the wave property (the square of the modulus of the complex number obtained by adding up the various possible paths) determines the probability of the photon landing at that point on the screen. Its as if nature had been fooling us into believing that light must be a classical wave, when all along the meaning of 'wavelength' and 'interference' are quite different to a classical wave. In Feynman's book 'QED' he talks about 'arrows' which are complex numbers represented in the complex plane which are rotating according to the frequency of the photon, thus describing a spiral as the photon moves along. The wavelength is the distance for which the arrow goes once around. Its a mathematical device (the complex plane does not exist as a real object) that however gives us the results of real experiments. 
A: A photon is a measurement on a quantum field. It's a "one time deal", if you like. Each photon has an energy and a helicity (sometimes confused with "spin"), but that's not enough to produce a "wavelength", which is a property of a classical electromagnetic wave. We only recover the wave by measuring many photons, which then approximate the classical wave shape. In order to have a sensible definition of wavelength, these photons all have to have a similar energy, so that the coherence length of the resulting wave is long (enough). Strictly speaking one would not assign that wavelength to the single photon since the single photon measurement can't tell us that the wave is sufficiently coherent. 
